package org.wu.framework.log.platform.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.wu.framework.web.spring.EasyController;
import org.springframework.web.bind.annotation.*;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.response.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import jakarta.annotation.Resource;
import org.wu.framework.log.platform.domain.model.request.log.RequestLog;
import org.wu.framework.log.platform.application.command.request.log.RequestLogRemoveCommand;
import org.wu.framework.log.platform.application.command.request.log.RequestLogStoryCommand;
import org.wu.framework.log.platform.application.command.request.log.RequestLogUpdateCommand;
import org.wu.framework.log.platform.application.command.request.log.RequestLogQueryListCommand;
import org.wu.framework.log.platform.application.command.request.log.RequestLogQueryOneCommand;
import org.wu.framework.log.platform.application.RequestLogApplication;
import org.wu.framework.log.platform.application.dto.RequestLogDTO;
import java.util.List;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
/**
 * describe 请求日志 
 *
 * @author Jia wei Wu
 * @date 2024/03/25 04:20 下午
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyController 
 **/
@Tag(name = "请求日志提供者")
@EasyController("/request/log")
public class RequestLogProvider  {

    @Resource
    private RequestLogApplication requestLogApplication;

    /**
     * describe 新增请求日志
     *
     * @param requestLogStoryCommand 新增请求日志     
     * @return {@link Result<RequestLog>} 请求日志新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/03/25 04:20 下午
     **/

    @Operation(summary = "新增请求日志")
    @PostMapping("/story")
    public Result<RequestLog> story(@RequestBody RequestLogStoryCommand requestLogStoryCommand){
        return requestLogApplication.story(requestLogStoryCommand);
    }
    /**
     * describe 批量新增请求日志
     *
     * @param requestLogStoryCommandList 批量新增请求日志     
     * @return {@link Result<List<RequestLog>>} 请求日志新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/03/25 04:20 下午
     **/

    @Operation(summary = "批量新增请求日志")
    @PostMapping("/batchStory")
    public Result<List<RequestLog>> batchStory(@RequestBody List<RequestLogStoryCommand> requestLogStoryCommandList){
        return requestLogApplication.batchStory(requestLogStoryCommandList);
    }
    /**
     * describe 更新请求日志
     *
     * @param requestLogUpdateCommand 更新请求日志     
     * @return {@link Result<RequestLog>} 请求日志领域对象     
     
     * @author Jia wei Wu
     * @date 2024/03/25 04:20 下午
     **/

    @Operation(summary = "更新请求日志")
    @PutMapping("/updateOne")
    public Result<RequestLog> updateOne(@RequestBody RequestLogUpdateCommand requestLogUpdateCommand){
        return requestLogApplication.updateOne(requestLogUpdateCommand);
    }
    /**
     * describe 查询单个请求日志
     *
     * @param requestLogQueryOneCommand 查询单个请求日志     
     * @return {@link Result<RequestLogDTO>} 请求日志DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/03/25 04:20 下午
     **/

    @Operation(summary = "查询单个请求日志")
    @GetMapping("/findOne")
    public Result<RequestLogDTO> findOne(@ModelAttribute RequestLogQueryOneCommand requestLogQueryOneCommand){
        return requestLogApplication.findOne(requestLogQueryOneCommand);
    }
    /**
     * describe 查询多个请求日志
     *
     * @param requestLogQueryListCommand 查询多个请求日志     
     * @return {@link Result<List<RequestLogDTO>>} 请求日志DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/03/25 04:20 下午
     **/

    @Operation(summary = "查询多个请求日志")
    @GetMapping("/findList")
    public Result<List<RequestLogDTO>> findList(@ModelAttribute RequestLogQueryListCommand requestLogQueryListCommand){
        return requestLogApplication.findList(requestLogQueryListCommand);
    }
    /**
     * describe 分页查询多个请求日志
     *
     * @param requestLogQueryListCommand 分页查询多个请求日志     
     * @return {@link Result<LazyPage<RequestLogDTO>>} 分页请求日志DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/03/25 04:20 下午
     **/

    @Operation(summary = "分页查询多个请求日志")
    @GetMapping("/findPage")
    public Result<LazyPage<RequestLogDTO>> findPage(@Parameter(description ="分页大小") @RequestParam(defaultValue = "10", value = "size") int size,
                           @Parameter(description ="当前页数") @RequestParam(defaultValue = "1", value = "current") int current,@ModelAttribute RequestLogQueryListCommand requestLogQueryListCommand){
        return requestLogApplication.findPage(size,current,requestLogQueryListCommand);
    }
    /**
     * describe 删除请求日志
     *
     * @param requestLogRemoveCommand 删除请求日志     
     * @return {@link Result<RequestLog>} 请求日志     
     
     * @author Jia wei Wu
     * @date 2024/03/25 04:20 下午
     **/

    @Operation(summary = "删除请求日志")
    @DeleteMapping("/remove")
    public Result<RequestLog> remove(@ModelAttribute RequestLogRemoveCommand requestLogRemoveCommand){
        return requestLogApplication.remove(requestLogRemoveCommand);
    }
}